void main() {
  // 准备购物车数据
  List carts = [
    {"count": 2, "price": 10.0, "selected": true},
    {"count": 1, "price": 30.0, "selected": true},
    {"count": 5, "price": 20.0, "selected": true}
  ];

  // print(carts);
  // 记录总金额
  double totalAmount = 0.0;

  // carts.forEach((item) {
  //   if (item['selected']) {
  //     totalAmount += item['count'] * item['price'];
  //   }
  //   ;
  // });
  for (dynamic item in carts) {
    if (item['selected']) {
      totalAmount += item['count'] * item['price'];
    }
  }
  print('总价格为：$totalAmount');
}
